/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jdOperaImpuesto.java
 *
 * Created on 15-sep-2011, 8:57:26
 */
package Impuestos;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.Utiles_MensajesDialogo;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import suministros.ejb30.TO.ImpuestoTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.entity.DetalleImpuestoFactor;
import suministros.ejb30.entity.DetalleImpuestoFactorPK;
import suministros.ejb30.entity.DetallePlantillaImpuesto;
import suministros.ejb30.entity.DetallePlantillaImpuestoPK;
import suministros.ejb30.entity.Impuesto;
import suministros.ejb30.entity.Tipo;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Luis_Angel
 */
public class jdOperaImpuesto extends javax.swing.JDialog {

    jifAdministraImpuestos fpadre;
    private Integer id_impuesto = null;

    /** Creates new form jdOperaImpuesto */
    public jdOperaImpuesto(java.awt.Frame parent, boolean modal, jifAdministraImpuestos fpadre) {
        super(parent, modal);
        initComponents();
        llenarComboTipoPlantillaImpuesto();
        this.fpadre = fpadre;
    }

    public void setDatos(ImpuestoTO impuesto) {
        this.jtfDescripCorta.setText(impuesto.getDescripcion_corta());
        this.jtfDescripLarga.setText(impuesto.getDescripcion_larga());
        this.jtfCuentaDebe.setText(impuesto.getCuenta_debe());
        this.jtfCuentaHaber.setText(impuesto.getCuenta_haber());
        this.jtfMontoDesde.setText(impuesto.getMonto_desde().toPlainString());
        this.jtfMontoHasta.setText(impuesto.getMonto_hasta().toPlainString());
        this.jtfPorcentaje.setText(impuesto.getPorcentaje().toPlainString());
        this.jcbTipo.setSelectedItem(impuesto.getEfecto().trim());

        id_impuesto = impuesto.getId_impuesto();
        for (TipoTO tt : cboBeanBindingTipo1.getLista()) {
            if (tt.getId_tabla_tipo().equals(impuesto.getId_plantilla())) {
                this.jcboPlantillaImpuesto.setSelectedItem(tt);
                break;
            }
        }
    }

    private void llenarComboTipoPlantillaImpuesto() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo1.clear();
        try {
            listaTipos1 = Listas.getTipo_porTabla("Tipo_Plantilla");

            this.cboBeanBindingTipo1.setLista(listaTipos1);
            this.bindingGroup.bind();
            this.jcboPlantillaImpuesto.updateUI();
            this.jcboPlantillaImpuesto.setSelectedIndex(0);
        } catch (Exception ex) {
            Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos Plantillas Impuesto\n" + ex.getMessage());
            ex.printStackTrace();

        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        jPanel2 = new javax.swing.JPanel();
        jbGuardar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtfDescripCorta = new javax.swing.JTextField();
        jtfDescripLarga = new javax.swing.JTextField();
        jcbTipo = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jtfCuentaDebe = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfCuentaHaber = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtfMontoHasta = new javax.swing.JTextField();
        jtfMontoDesde = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jcboPlantillaImpuesto = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jtfPorcentaje = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Operaciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 11), new java.awt.Color(0, 0, 172))); // NOI18N

        jbGuardar.setFont(new java.awt.Font("Arial", 1, 11));
        jbGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/document_save.png"))); // NOI18N
        jbGuardar.setMnemonic('A');
        jbGuardar.setText("GUARDAR");
        jbGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbGuardarActionPerformed(evt);
            }
        });
        jbGuardar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbGuardarKeyPressed(evt);
            }
        });

        jbCancelar.setFont(new java.awt.Font("Arial", 1, 11));
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/exit.png"))); // NOI18N
        jbCancelar.setMnemonic('C');
        jbCancelar.setText("SALIR");
        jbCancelar.setToolTipText("Cancelar la Operacion");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });
        jbCancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbCancelarKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(151, Short.MAX_VALUE)
                .addComponent(jbGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(149, 149, 149))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbCancelar)
                    .addComponent(jbGuardar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos de impuesto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 11), new java.awt.Color(0, 0, 172))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel1.setText("DESCRIPCION CORTA");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel2.setText("DESCRIPCION LARGA");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel3.setText("EFECTO");

        jcbTipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+", "-" }));

        jLabel4.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel4.setText("CUENTA DEBE");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel6.setText("CUENTA HABER");

        jLabel7.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel7.setText("MONTO HASTA");

        jtfMontoHasta.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jtfMontoDesde.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jLabel8.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel8.setText("MONTO DESDE");

        jLabel17.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel17.setText("PLANT.IMPUESTO");

        jcboPlantillaImpuesto.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo1, eLProperty, jcboPlantillaImpuesto);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboPlantillaImpuesto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcboPlantillaImpuestoItemStateChanged(evt);
            }
        });
        jcboPlantillaImpuesto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboPlantillaImpuestoKeyPressed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel9.setText("PORCENTAJE");

        jtfPorcentaje.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jtfDescripCorta, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(32, 32, 32)
                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jtfPorcentaje, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jtfDescripLarga, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jtfCuentaDebe, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(4, 4, 4)
                        .addComponent(jtfMontoDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jtfCuentaHaber, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(4, 4, 4)
                        .addComponent(jtfMontoHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jLabel17)
                        .addGap(28, 28, 28)
                        .addComponent(jcboPlantillaImpuesto, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(jcbTipo, 0, 39, Short.MAX_VALUE)))
                .addGap(10, 10, 10))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel1))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jtfDescripCorta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel9)
                        .addComponent(jtfPorcentaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel2))
                    .addComponent(jtfDescripLarga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel4))
                    .addComponent(jtfCuentaDebe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel8))
                    .addComponent(jtfMontoDesde, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel6))
                    .addComponent(jtfCuentaHaber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel7))
                    .addComponent(jtfMontoHasta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabel17))
                    .addComponent(jcboPlantillaImpuesto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcbTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)))))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void guardar()throws Exception{
        Impuesto impuesto_nuevo = new Impuesto();
            impuesto_nuevo.setCtaDebe(this.jtfCuentaDebe.getText().trim());
            impuesto_nuevo.setCtaHaber(this.jtfCuentaHaber.getText().trim());
            impuesto_nuevo.setDescripcionImpuesto(this.jtfDescripCorta.getText().trim());
            impuesto_nuevo.setDescripcionLargaImpuesto(this.jtfDescripLarga.getText().trim());
            impuesto_nuevo.setEfecto(String.valueOf(this.jcbTipo.getSelectedItem()).charAt(0));
            impuesto_nuevo.setCtaDebe(this.jtfCuentaDebe.getText().trim());
            impuesto_nuevo.setCtaDebe(this.jtfCuentaDebe.getText().trim());
            impuesto_nuevo.setIdImpuesto(id_impuesto);


            DetalleImpuestoFactor dif = new DetalleImpuestoFactor();
            dif.setMontoDesde(new BigDecimal(this.jtfMontoDesde.getText().trim()));
            dif.setMontoHasta(new BigDecimal(this.jtfMontoHasta.getText().trim()));
            DetalleImpuestoFactorPK dpk = new DetalleImpuestoFactorPK(id_impuesto,new BigDecimal(this.jtfPorcentaje.getText().trim()));
            dif.setDetalleImpuestoFactorPK(dpk);

            List<DetalleImpuestoFactor> lista_factor = new ArrayList<DetalleImpuestoFactor>();
            lista_factor.add(dif);
            impuesto_nuevo.setDetalleImpuestoFactorList(lista_factor);

            DetallePlantillaImpuesto dpi = new DetallePlantillaImpuesto();
            DetallePlantillaImpuestoPK dpik = new DetallePlantillaImpuestoPK();
            dpik.setIdPlantilla(((TipoTO)this.jcboPlantillaImpuesto.getSelectedItem()).getId_tabla_tipo());
            dpi.setDetallePlantillaImpuestoPK(dpik);
            GestionPedidosDelegate.getInstance().operaImpuesto(impuesto_nuevo,dpi);
            Utiles_MensajesDialogo.mensajeExito();
            this.dispose();
            this.fpadre.llenaTabla();
    }

    private void jbGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbGuardarActionPerformed
        // TODO add your handling code here:
        int res = javax.swing.JOptionPane.showConfirmDialog(this, "Esta seguro de realizar la operacion?",
                "Confirmar", javax.swing.JOptionPane.YES_NO_OPTION);
        if (res == javax.swing.JOptionPane.YES_OPTION) {
            
            try {
                guardar();
            
            } catch (Exception ex) {
                try {
                    guardar();
                } catch (Exception ex1) {
                    Logger.getLogger(jdOperaImpuesto.class.getName()).log(Level.SEVERE, null, ex1);
                }
            }
        }
    }//GEN-LAST:event_jbGuardarActionPerformed

    private void jbGuardarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbGuardarKeyPressed
        // TODO add your handling code here:
}//GEN-LAST:event_jbGuardarKeyPressed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed

        this.dispose();
}//GEN-LAST:event_jbCancelarActionPerformed

    private void jbCancelarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbCancelarKeyPressed
}//GEN-LAST:event_jbCancelarKeyPressed

    private void jcboPlantillaImpuestoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboPlantillaImpuestoItemStateChanged
        //        this.jcboComprobante.requestFocus();
}//GEN-LAST:event_jcboPlantillaImpuestoItemStateChanged

    private void jcboPlantillaImpuestoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboPlantillaImpuestoKeyPressed
    }//GEN-LAST:event_jcboPlantillaImpuestoKeyPressed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbGuardar;
    private javax.swing.JComboBox jcbTipo;
    private javax.swing.JComboBox jcboPlantillaImpuesto;
    private javax.swing.JTextField jtfCuentaDebe;
    private javax.swing.JTextField jtfCuentaHaber;
    private javax.swing.JTextField jtfDescripCorta;
    private javax.swing.JTextField jtfDescripLarga;
    private javax.swing.JTextField jtfMontoDesde;
    private javax.swing.JTextField jtfMontoHasta;
    private javax.swing.JTextField jtfPorcentaje;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
